// defineProperty 无法拦截数组元素的某些操作
const obj = {};

let _items = ['a'];
Object.defineProperty(obj, 'items', {
    get() {
        console.log('\naccess items');
        return _items;
    },

    set(val) {
        console.log('items set to ', val);
        _items = val;
    },
});

console.log(obj.items);
obj.items.push('b');
console.log(obj.items);
delete obj.items[0];
console.log(obj.items);
